#ifndef TRANSLATOR_H_INCLUDED
#define TRANSLATOR_H_INCLUDED

#ifndef GAUZE_NUM
#define GAUZE_NUM 16
#endif

#define LEFTSIDE    1
#define RIGHTSIDE   2


typedef struct _TRANSLATOR  TRANSLATOR;

struct _TRANSLATOR
{
    char pat_fn[256];
    char cnt_fn[256];
    unsigned char *prm_buf;
    unsigned char *pat_buf;
    int width;
    int height;
    int gauze_pos[GAUZE_NUM];
    char gauze_dir[GAUZE_NUM];
    char io[GAUZE_NUM];
};

/*
 *
 */
void translator_get_color_range (uchar *pat_buf,
                                 int width,
                                 int height,
                                 int *prow,
                                 int *pcolor,
                                 int *start_pos,
                                 int *end_pos);
/*
 *
 */
int translator_get_yinta_range (uchar *patbuf ,
                                int width,
                                int height,
                                int *prow,
                                int *start_pos,
                                int *end_pos,
                                int *pcolormask);
/*
 *
 */
int translator_is_one_side (uchar *patbuf ,
                            int width,
                            int height,
                            int *prow,
                            int *pcolor);
/*
 *
 */
char translator_get_color (uchar *pat_buf,
                           int width,
                           int height,
                           int x,
                           int y);
/*
 *
 */
int translator_get_gauze_pos(MH_KNIT *p, int row, int *gsp);

#if 0
TRANSLATOR* translator_new (const char *cnt_fn, const char *pat_fn, const char *prm_fn, int type);
int translator_init (TRANSLATOR *translator, const char *cnt_fn,
                     const char *pat_fn, const char *prm_fn, int type);
int translator_read_patfile (TRANSLATOR *translator, const char *pat_fn, int type);
int translator_read_prmfile (TRANSLATOR *translator, const char *prm_fn);
void translator_exec (TRANSLATOR *simulator, int mrow, unsigned char *pcon_buf, unsigned char *pcnt_buf);
int translator_save_patfile (TRANSLATOR *simulator);
int translator_save_cntfile (TRANSLATOR *simulator);
void translator_free (TRANSLATOR *simulator);
int translator_update_gauze_pos (TRANSLATOR *simulator, int mrow, int gauze, int pos);
void translator_iterate_loop (TRANSLATOR *translator, unsigned char *des);
#endif
void translator_set_stitch (TRANSLATOR *translator,
                            int *fstitch,
                            int *bstitch,
                            unsigned char *pcon_buf);
#endif // SIMULATOR_H_INCLUDED
